define('components/banner', ['text!/components/banner.html'], function(template) {
  return {
    template: template,
    data: function() {
      return {
        search: '',
        hotSearch: [{
          name: '自行车'
        }, {
          name: '电动车'
        }, {
          name: '笔记本'
        }, {
          name: '教材'
        }]
      };
    },
    replace: true,
    created: function() {
      var vm = this;
      vm.$router.beforeEach(function(transition) {
        var to = transition.to;
        if (to.name === 'search') {
          vm.search = to.query.text;
        } else {
          vm.search = '';
        }
        transition.next();
      });
    },
    methods: {
      searchGo: function() {
        var vm = this;
        vm.$router.go({
          name: 'search',
          query: {
            text: vm.search,
            t: Date.now()
          }
        });
      },
      loginOut: function() {
        var vm = this;
        vm.$http.post('/user/loginOut').then(function(res) {
          res = res.data;
          if (res.code !== 0) {
            alert(res.message);
            return;
          }
          vm.user.isLogin = false;
          vm.user.userName = false;
          vm.user.uid = 0;
          vm.user.avatar = false;
          vm.user.account = false;
          if (vm.$route.mustLogin === true) {
            vm.$router.go({
              name: 'index'
            });
          }
        });
      }
    },
    props: ['user', 'small', 'box']
  };
});